﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace XqWebSite
{
    public partial class WebForm49 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)//判断是否回发
            {
                if (Request["ID"] != null)//判断是否有参数传入
                {
                    InitData();//执行初始化函数
                }
            }
        }
        protected void InitData()
        {
            string id = Request["ID"].ToString();
            try
            {
                string SQL = "select * from Toushu where ID='" + id + "'";
                DataTable dt = DBHelper.GetDataSet(SQL).Tables[0];//获取对应的参数并且对页面进行绑定
                if (dt.Rows.Count > 0)
                {
                   
                    this.Tex_nr.Text = dt.Rows[0]["Neirong"].ToString();
                    this.Tex_sj.Text = dt.Rows[0]["TousuShijian"].ToString();
                    this.Tex_tsdr.Text = dt.Rows[0]["named"].ToString();
                }
            }
            catch
            {
            }
        }

        protected void But_tj_Click(object sender, EventArgs e)
        {
            string SQL = "";
            bool iRet = false;
            string id = Tex_id.Text;
            
                
                SQL = "update Toushu set Neirong ='" + Tex_nr.Text + "',TousuShijian ='" + Tex_sj.Text + "',named ='" + Tex_tsdr.Text
                      + "' where ID='" + id + "'";//执行更新操作
                iRet = DBHelper.ExecSql(SQL);
            
           
            if (iRet)
            {
                DBHelper.ShowMessage(Page, "恭喜您，操作成功！", "");
                Tex_nr.Text = "";
                Tex_sj.Text = "";
                Tex_tsdr.Text = "";
            }
            else
            {
                DBHelper.ShowMessage(Page, "对不起，操作失败！", "");
            }

          
        }

        protected void But_qx_Click(object sender, EventArgs e)
        {
            Tex_nr.Text = "";
            Tex_sj.Text = "";
            Tex_tsdr.Text = "";
            Response.Redirect("ZhTousuguanli.aspx");
        }
    }
}